home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / util / rexx / WebChat.lha / webchat / install / web.rexx next >
Encoding:
OS/2 REXX Batch file  |  1997-10-31  |  2.3 KB  |  100 lines

  1. /*         Web mailing list updater V1.0       */
  2. /* A script designed to take the output from   */
  3. /* a form & use the output to make a web based */
  4. /* mailing list. READ the docs!!               */
  5. /*  © William P Wilson - 25.10.97 E&OE         */
  6. /*                  north@lantic16.demon.co.uk */
  7.  
  8. parse arg filen
  9.  
  10. nami = strip(filen)
  11.  
  12. namy = delstr(nami,1,1)
  13. len = length(namy)
  14. name = delstr(namy,len,1)
  15.  
  16. open(pat,'WebChat:htmlpath','R')
  17. open(kid,'ENV:Webchat.pref','R')
  18. open(his,'WebChat:HTML/buffer','R')
  19.  
  20. dest = 'WebChat:HTML/buffer'
  21. formid = readln(kid)
  22. path = readln(pat)
  23. start = 'WebChat:HTML/default-top'
  24. end = 'WebChat:HTML/default-end'
  25.  
  26. idch = 0
  27.  
  28. if open(file, name, 'R')                /* opens file */
  29. then do while ~eof(file)                /* repeat until EOF */
  30.  data = readln(file)                    /* gets data */
  31.  if upper(left(data,7)) = 'FORMID=' then do        /* changes first word into caps to check for formid */
  32.    checkid = word(translate(data,'  ','=&'),2)
  33.    if upper(formid) = upper(checkid) then
  34.    call getstrings
  35.  end
  36. end
  37.  
  38. if idch = 0 then do
  39.  say 'Wrong formid (not 'formid' but 'checkid').'
  40.  exit
  41. end
  42. if idch = 1 then do
  43.  open(one,start,'R')
  44.  open(two,dest,'R')
  45.  open(three,end,'R')
  46.  open(html,path,'W')
  47.  
  48.  dig = readch(one,65535)
  49.  next = readch(two,65535)
  50.  never = readch(three,65535)
  51.  new = (dig next never)
  52.  
  53.  writech(html,new)
  54.  
  55.  call close(one)
  56.  call close(two)
  57.  call close(three)
  58.  call close(file)
  59.  call close(end)
  60.  call close(kid)
  61.  call close(his)
  62. end
  63. exit
  64.  
  65. getstrings:
  66.  
  67. idch = 1
  68. fdat = translate(data,' ','&')                /* this bit of the script was nicked from Mat Bettinson's */
  69. do i = 1 to words(fdat)                    /* formdecoder script he wrote for CU-Amiga :) */
  70.   set = translate(word(fdat,i),' ','=')
  71.  
  72.   name = word(set,1) ; res = translate(word(set,2),' ','+')
  73.   ind = 1
  74.   do forever
  75.     pos = index(res,'%',ind)
  76.     if pos = 0 then break
  77.     hex = substr(res,pos+1,2)
  78.     if hex = '0D' then do                /* detects newline code & replaces with <BR> */
  79.      inchar = '<BR>'||x2c(hex)
  80.      end
  81.      else do
  82.      inchar = x2c(hex)
  83.     end
  84.     res = left(res,pos-1)||inchar||substr(res,pos+3)
  85.     ind = pos + 1
  86.   end
  87.  
  88. open(goto,dest,'A')
  89. if name = 'name' then do
  90.  ma = ('<DT><B>'res' wrote this on '||date()' :</B>')
  91.  writeln(goto,ma)
  92. end
  93. if name = 'message' then do
  94.  mz = ('<DD>'res'<BR><P>')
  95.  writeln(goto,mz)
  96. end
  97. end
  98. call close(goto)
  99. return
  100.